package com.secxiot.common.converter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
public class DateLongConverter implements Converter<Long, Date> {

    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public Date convert(Long source) {
        if (source == null) {
            return null;
        }
        try {
            Date date = new Date(source);
            return date;
        } catch (Exception e) {
            log.error("日期转换错误,Long", e);
        }

        return null;
    }
}
